#ifndef _PROTOCOL_SERIALIZER_H_
#define _PROTOCOL_SERIALIZER_H_


#include <iostream>
#include <string>
#include <fstream>
#include "TestProtocol.h"
#include "general.h"

using namespace std;

// Singleton class
class ProtocolSerializer
{
  friend ostream& operator<<
    (ostream& out, const ProtocolSerializer& obj);
public:
  static ProtocolSerializer& getInstance()
  {
    static ProtocolSerializer _instance; // Guaranteed to be destroyed.
                                         // Instantiated on first use.
    return _instance;
  };
  void SetHeader(ToPSyncMsgHeader h);

  
private:    
  ProtocolSerializer(){};   // Constructor? (the {} brackets) are needed here.
              // Dont forget to declare these two. You want to make sure they
              // are unaccessable otherwise you may accidently get copies of
              // your singleton appearing.
  void operator=(ProtocolSerializer const&);      // Don't implement
  ProtocolSerializer(ProtocolSerializer const&);  // Don't Implement
  ToPSyncMsgHeader _header;
};


extern ostream& operator<<(ostream& out, const ToPSyncMsgHeader& msgh);

extern void SerializeToPSyncMsgHeader(ToPSyncMsgHeader* pMsgHeader);
extern void SerializeToPSyncMsgHeaderBinData(const uint8* dataPtr, uint8 len);
extern void InitSerializer(const char* fname);
extern void SerializeSpiWriteByte(uint32 address, uint8 data);

#endif // _PROTOCOL_SERIALIZER_H_

// EOF
